package com.etc.controller;


import com.etc.entity.FxPlaylist;
import com.etc.service.FxPlaylistService;

import com.etc.util.ResponseData;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin("*")
public class FxPlaylistController {
    @Autowired
    FxPlaylistService service;

    Logger logger = (Logger) LogManager.getLogger();



    @GetMapping(value = "Playlist_ByPage")
    public List<FxPlaylist> Select_ByPage(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo, @RequestParam(value = "pageSize",defaultValue = "6") int pageSize,@RequestParam(value = "keywords") String keywords) {
        List<FxPlaylist> fxPlaylists = service.selectByPage(pageNo, pageSize, keywords);
        logger.info("Select_ByPage"+fxPlaylists);
        System.out.println(fxPlaylists);
        return fxPlaylists;
    }
    @GetMapping(value = "Playlist_ByPage/")
    public ResponseData SelectByPage(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo, @RequestParam(value = "pageSize",defaultValue = "6") int pageSize, @RequestParam(value = "keywords") String keywords) {
        List<FxPlaylist> fxPlaylists = service.selectByPage(pageNo, pageSize, keywords);
        ResponseData responseData = new ResponseData();
        responseData.setData(fxPlaylists);
        return responseData;
    }
}
